package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FloPopZx;
import com.ruoyi.system.service.IFloPopZxService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流动人口注销Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/ld_zx")
public class FloPopZxController extends BaseController
{
    private String prefix = "system/ld_zx";

    @Autowired
    private IFloPopZxService floPopZxService;

    @RequiresPermissions("system:ld_zx:view")
    @GetMapping()
    public String ld_zx()
    {
        return prefix + "/ld_zx";
    }

    /**
     * 查询流动人口注销列表
     */
    @RequiresPermissions("system:ld_zx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FloPopZx floPopZx)
    {
        startPage();
        List<FloPopZx> list = floPopZxService.selectFloPopZxList(floPopZx);
        return getDataTable(list);
    }

    /**
     * 导出流动人口注销列表
     */
    @RequiresPermissions("system:ld_zx:export")
    @Log(title = "流动人口注销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FloPopZx floPopZx)
    {
        List<FloPopZx> list = floPopZxService.selectFloPopZxList(floPopZx);
        ExcelUtil<FloPopZx> util = new ExcelUtil<FloPopZx>(FloPopZx.class);
        return util.exportExcel(list, "流动人口注销数据");
    }

    /**
     * 新增流动人口注销
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流动人口注销
     */
    @RequiresPermissions("system:ld_zx:add")
    @Log(title = "流动人口注销", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FloPopZx floPopZx)
    {
        return toAjax(floPopZxService.insertFloPopZx(floPopZx));
    }

    /**
     * 修改流动人口注销
     */
    @RequiresPermissions("system:ld_zx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FloPopZx floPopZx = floPopZxService.selectFloPopZxById(id);
        mmap.put("floPopZx", floPopZx);
        return prefix + "/edit";
    }

    /**
     * 修改保存流动人口注销
     */
    @RequiresPermissions("system:ld_zx:edit")
    @Log(title = "流动人口注销", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FloPopZx floPopZx)
    {
        return toAjax(floPopZxService.updateFloPopZx(floPopZx));
    }

    /**
     * 删除流动人口注销
     */
    @RequiresPermissions("system:ld_zx:remove")
    @Log(title = "流动人口注销", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(floPopZxService.deleteFloPopZxByIds(ids));
    }
}
